cet.h inifile.h gbfile.h session.h src/core/datetime.h \
src/core/optional.h gbser.h
mynav.o: mynav.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
- inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h
+ inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
+ mynav.h format.h
navicache.o: navicache.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
cet_util.h src/core/file.h
gbfile.h session.h src/core/datetime.h src/core/optional.h vecs.h \
format.h gpx.h src/core/file.h src/core/xmlstreamwriter.h \
src/core/xmltag.h legacyformat.h gbversion.h src/core/logging.h xcsv.h \
- ggv_bin.h
+ ggv_bin.h mynav.h
vidaone.o: vidaone.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h
vitosmt.o: vitosmt.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
/*
Handle MyNav TRC format .trc and .ftn files
- Copyright (c) 2014 Ralf Horstmann <ralf@ackstorm.de>
- Copyright (C) 2014 Robert Lipe, robertlipe+source@gpsbabel.org
+ For information on the data format see
+ http://www.mynav.it/hwdoc/dev/TRC_Format_Spec.pdf
+
+ Copyright (c) 2014-2020 Ralf Horstmann <ralf@ackstorm.de>
+ Copyright (C) 2014-2020 Robert Lipe, robertlipe+source@gpsbabel.org
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
*/
-#include "defs.h"
+#include <QtCore/QChar>
#include <QtCore/QDebug>
+#include <QtCore/QIODevice>
+#include <QtCore/QString>
#include <QtCore/QStringList>
+#include <QtCore/QtGlobal>
+
+#include <src/core/textstream.h>
+
+#include "mynav.h"
+
+/***************************************************************************
+ * local helper functions *
+ ***************************************************************************/
-#define MYNAME "mynav"
-
-enum field_e {
- fld_type = 0,
- fld_lon,
- fld_lat,
- fld_direction,
- fld_speed,
- fld_altitude,
- fld_timestamp,
- fld_duration,
- fld_gps_valid,
- fld_distance,
- fld_ascent,
- fld_cadence,
- fld_heart_rate,
- fld_id,
- fld_total_duration,
- fld_terminator
-};
-
-static route_head* mynav_track;
-static gbfile* fin;
-
-//***************************************************************************
-// local helper functions
-//***************************************************************************
-static void
-mynav_rd_line(const QString& line)
+void
+MyNavFormat::read_line(const QString& line, route_head* track)
{
QStringList fields = line.split("|");
// only type 1 and type 5 lines contain coordinates
bool ok = false;
- int val_type = fields.at(fld_type).trimmed().toInt(&ok);
+ int line_type = fields.at(fld_type).trimmed().toInt(&ok);
if (!ok) {
return;
}
- if (val_type != 1 && val_type != 5) {
+ if (line_type != line_sensors && line_type != line_gps) {
return;
}
}
}
- track_add_wpt(mynav_track, wpt);
+ track_add_wpt(track, wpt);
}
+/***************************************************************************
+ * entry points called by gpsbabel main process *
+ ***************************************************************************/
-//***************************************************************************
-// global callbacks called by gpsbabel main process
-//***************************************************************************
-
-static void
-mynav_rd_init(const QString& fname)
+void
+MyNavFormat::rd_init(const QString& fname)
{
- fin = gbfopen(fname, "rb", MYNAME);
- mynav_track = route_head_alloc();
- track_add_head(mynav_track);
+ read_fname = fname;
}
-static void
-mynav_rd_deinit()
+void
+MyNavFormat::rd_deinit()
{
- gbfclose(fin);
+ read_fname.clear();
}
-static void
-mynav_rd()
+void
+MyNavFormat::read()
{
- QString buff;
+ gpsbabel::TextStream stream;
+ stream.open(read_fname, QIODevice::ReadOnly, "mynav");
+
+ route_head* track = route_head_alloc();
+ track_add_head(track);
- while ((buff = gbfgetstr(fin)), !buff.isNull()) {
- buff = buff.trimmed();
- if ((buff.isEmpty()) || (buff[0] == '#')) {
+ QString buf;
+ while (stream.readLineInto(&buf)) {
+ buf = buf.trimmed();
+ if ((buf.isEmpty()) || buf.startsWith('#')) {
continue;
}
- mynav_rd_line(buff);
+ read_line(buf, track);
}
-}
-ff_vecs_t mynav_vecs = {
- ff_type_file,
- {
- ff_cap_none, // waypoints
- ff_cap_read, // tracks
- ff_cap_none // routes
- },
- mynav_rd_init, // rd_init
- nullptr, // wr_init
- mynav_rd_deinit, // rd_deinit
- nullptr, // wr_deinit
- mynav_rd, // read
- nullptr, // write
- nullptr, // exit
- nullptr, //args
- CET_CHARSET_ASCII, 0 //encode,fixed_encode
- //NULL //name dynamic/internal?
- , NULL_POS_OPS,
- nullptr
-};
+ stream.close();
+}
--- /dev/null
+/*
+ Handle MyNav TRC format .trc and .ftn files
+
+ Copyright (c) 2014-2020 Ralf Horstmann <ralf@ackstorm.de>
+ Copyright (C) 2014-2020 Robert Lipe, robertlipe+source@gpsbabel.org
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ */
+
+#ifndef MYNAV_H_INCLUDED_
+#define MYNAV_H_INCLUDED_
+
+#include <QtCore/QString>
+#include <QtCore/QVector>
+
+#include "defs.h"
+#include "format.h"
+
+class MyNavFormat : public Format
+{
+public:
+ ff_type get_type() const override
+ {
+ return ff_type_file;
+ }
+
+ QVector<ff_cap> get_cap() const override
+ {
+ return {
+ ff_cap_none, // waypoints
+ ff_cap_read, // tracks
+ ff_cap_none // routes
+ };
+ }
+
+ QString get_encode() const override
+ {
+ return CET_CHARSET_ASCII;
+ }
+
+ int get_fixed_encode() const override
+ {
+ return 0;
+ }
+
+ void rd_init(const QString& fname) override;
+ void read() override;
+ void rd_deinit() override;
+
+private:
+ enum field_e {
+ fld_type = 0,
+ fld_lon,
+ fld_lat,
+ fld_direction,
+ fld_speed,
+ fld_altitude,
+ fld_timestamp,
+ fld_duration,
+ fld_gps_valid,
+ fld_distance,
+ fld_ascent,
+ fld_cadence,
+ fld_heart_rate,
+ fld_id,
+ fld_total_duration,
+ fld_terminator
+ };
+
+ enum line_e {
+ line_header = 0,
+ line_sensors = 1,
+ line_geonote = 2,
+ line_gps = 5,
+ line_lap_pause = 7,
+ line_lap_restart = 8,
+ line_total = 9,
+ line_lap_start = 10,
+ line_lap_end = 11,
+ };
+
+ static void read_line(const QString& line, route_head* track);
+
+ QString read_fname;
+
+};
+
+#endif
#include "ggv_bin.h"
#include "gpx.h"
#include "legacyformat.h"
+#include "mynav.h"
#if CSVFMTS_ENABLED
extern ff_vecs_t f90g_track_vecs;
extern ff_vecs_t mapfactor_vecs;
extern ff_vecs_t energympro_vecs;
-extern ff_vecs_t mynav_vecs;
extern ff_vecs_t geojson_vecs;
extern ff_vecs_t globalsat_sport_vecs;
#endif // MAXIMAL_ENABLED
LegacyFormat f90g_track_fmt {f90g_track_vecs};
LegacyFormat mapfactor_fmt {mapfactor_vecs};
LegacyFormat energympro_fmt {energympro_vecs};
- LegacyFormat mynav_fmt {mynav_vecs};
+ MyNavFormat mynav_fmt;
LegacyFormat geojson_fmt {geojson_vecs};
GgvBinFormat ggv_bin_fmt;
LegacyFormat globalsat_sport_fmt {globalsat_sport_vecs};